import request from "@/utils/request";
import { type findePasswordRes, type findPasswordReq, type loginForm, type loginResponseData, type sendEmail, type userInfoReponseData, type validateEmailCodeReq } from '@/api/user/type'

// 统一接口
enum API {
    LOGIN_URL = '/auth/login',
    USERINFO_URL = '/user/info',
    FINDPASSWORD_URL = 'changeuserinfo/findPassWord',
    // 邮箱验证码
    EMAILCONDE_URL = 'auth/emailCode',
   VALIDATEEMAILCODE_URL=  'auth/validateEmailCode'
}

// 登录接口方法
export const reqLogin = (data: loginForm) => request.post<any, loginResponseData>(API.LOGIN_URL, data)

//获取用户信息

export const reqUserInfo = () => request.get<any, userInfoReponseData>(API.USERINFO_URL)

//找回密码
export const reqFindPassword= (data: findPasswordReq) => request.post<any , findePasswordRes>(API.FINDPASSWORD_URL, data)

//获取邮箱验证码
export const sendEmailCaptcha = (data: sendEmail) => request.post(API.EMAILCONDE_URL, data)

//验证邮箱验证码是否正确
export const reqValidateEmailCode = (data: validateEmailCodeReq ) => request.post(API.VALIDATEEMAILCODE_URL, data)